package javaJob.exercise;

import java.util.Arrays;

public class exercise1 {
    public int[] twoSum(int[] nums, int target) {
        int[] coord = new int[2];
        int record=0;
        for(int num1=0;num1<nums.length;num1++){
            for(int num2=num1+1;num2<nums.length;num2++){
                if(target==nums[num1]+nums[num2] && record==0){
//                if(target==nums[num1]+nums[num2] && record==0){
                    coord[0]=num1;
                    coord[1]=num2;
//                    int[] coord={num1,num2};
                    System.out.println(nums[num1]);
                    System.out.println(nums[num2]);
                    record=1;
                    break;
                }
            }
            if (record==1){
                break;
            }
        }
        return coord;
    }

    public static void main(String[] args) {
        int[] nums ={2,7,11,15};
        int target = 9;
//        int[] nums ={3,2,4};
//        int target = 6;
//        int[] nums = {3,3};
//        int target = 6;

//        int[] a = new exercise1().twoSum(nums,target);
        exercise1 a = new exercise1();
        int[] num =a.twoSum(nums,target);
        System.out.println(Arrays.toString(num));
    }
}
